import java.io.Console;

public class MyConsole {
	public static void main(String[] args) {
		Console console = System.console();

		if (console == null) {
			System.out.println("Console is not available");
			System.exit(1);
		}

		String username = console.readLine("Enter username ");
		char[] password = console.readPassword("Enter password");
		System.out.println("Hello " + username
				+ ". Nice to see you again. Your password is: " + password);

	}
}
